using UnityEngine;
using UnityEngine.AI;

public class NPCController : MonoBehaviour
{
    private NavMeshAgent navMeshAgent;
    private NPCMovement npcWanderScript;
    private NPCFollow npcFollowScript;
    private NPCStop npcStopScript;

    void Start()
    {
        navMeshAgent = GetComponent<NavMeshAgent>();
        npcWanderScript = GetComponent<NPCMovement>();
        npcFollowScript = GetComponent<NPCFollow>();
        npcStopScript = GetComponent<NPCStop>();

        // Start with wandering
        EnableWander();
        EnableStop();
    }

    void Update()
    {
        // Check for player input or other conditions to switch behaviors
        if (Input.GetKeyDown(KeyCode.F))
        {
            // Toggle between wandering and following when the 'F' key is pressed
            if (npcWanderScript.enabled)
                EnableFollow();
            else
                EnableWander();
        }
    }

    void EnableWander()
    {
        npcWanderScript.enabled = true;
        npcFollowScript.enabled = false;
    }

    void EnableFollow()
    {
        npcWanderScript.enabled = false;
        npcFollowScript.enabled = true;
    }
    void EnableStop()
    {
        npcStopScript.enabled = true;
    }
}
